package com.wutuo.roster.provider.component;

import com.wutuo.roster.api.response.ParentsResponse;
import org.apache.commons.collections.CollectionUtils;

import java.util.*;

public class ParentUtil {

    public static List<Long> getRosterIds(List<ParentsResponse> response) {

        if (CollectionUtils.isEmpty(response)) {
            return Collections.emptyList();
        }

        List<Long> rosterIds = new ArrayList<>();
        for (ParentsResponse item : response) {
            rosterIds.add(item.getRosterId());
        }

        return rosterIds;
    }

    public static Set<String> getParentsAccountList(List<ParentsResponse> response) {

        if (CollectionUtils.isEmpty(response)) {
            return Collections.emptySet();
        }

        Set<String> userAccounts = new HashSet<>();
        for (ParentsResponse item : response) {
            userAccounts.add(item.getUserPhone());
        }

        return userAccounts;
    }
}
